#!/usr/bin/env python3.4

class Terminal(type):
	def __init__(self, cls, bases, namespace):
		print("init of type", self.__name__)
# singleton forbidding method
#		for base in bases:
#			if isinstance(base, Terminal):
#				raise TypeError("class %s cannot inherit from class %s" % (self.__name__, base.__name__))
		super(Terminal, self).__init__(cls, bases, namespace)
	def __call__(self, *args, **kwargs):
		print("call of", self.__name__)
		return super(Terminal, self).__call__(*args, **kwargs)

class Foo(metaclass=Terminal):
	def __new__(cls, *args, **kwargs):
		print("new of cls Foo")
		return super().__new__(cls)
	
	def __init__(self, price):
		self._val = price
		print("init of class Foo")

class Bar(Foo):
	def __new__(cls, *args, **kwargs):
		print("new of cls", cls.__name__)
		return super().__new__(cls, *args, **kwargs)

	def __init__(self, total, price):
		self._total = total
		print("init of class Bar")
		super().__init__(price)

obj = Bar(10, 5)
print(obj._total)
